Skip to content

Conversation

@biqiboqi
Copy link
Contributor

No description provided.

This was linked to issues Oct 23, 2025
@bialger
Copy link
Contributor

bialger commented Oct 23, 2025

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Contributor

@bialger bialger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All in all, titanic work has been done. It is fantastic, and I don't see any major architecture flaws. Although there is a place to grow and some simple mistakes. Please fix them. Really good job, thank you.

@bialger
Copy link
Contributor

bialger commented Nov 10, 2025

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +11 to +35
const Token& VectorTokenStream::Peek(size_t k) {
const Token* token = TryPeek(k);

if (token != nullptr) {
return *token;
}

if (last_ != nullptr) {
return *last_;
}

if (!tokens_.empty()) {
return *tokens_.back();
}

throw std::out_of_range("VectorTokenStream::Peek out of range");
}

TokenPtr VectorTokenStream::Consume() {
if (index_ < tokens_.size()) {
last_ = tokens_[index_].get();
return std::move(tokens_[index_++]);
}

last_ = nullptr;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid returning references to tokens that were moved out

In VectorTokenStream::Consume the stream stores a raw pointer to the consumed token (last_ = tokens_[index_].get();) and then moves the unique_ptr out to the caller. Peek and LastConsumed later return *last_ when no tokens remain. If the caller releases the returned TokenPtr—which destroys the token—the stored pointer dangles and the next call to Peek or LastConsumed dereferences freed memory. The stream should either retain ownership of consumed tokens or avoid returning pointers/references after handing ownership to the caller; otherwise calls past EOF have undefined behavior.

Useful? React with 👍 / 👎.

Copy link
Contributor

@bialger bialger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot review

Copy link

Copilot AI commented Nov 10, 2025

@bialger I've opened a new pull request, #26, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a comprehensive parser infrastructure for the Ovum compiler. It implements a type system with type references, nullability tracking, AST nodes for expressions/statements/declarations, visitor patterns for AST traversal, parser states, diagnostics with severity levels, and Pratt parsing infrastructure.

  • Introduces TypeReference class with qualified names, type arguments, nullability, and resolution tracking
  • Implements full AST node hierarchy including expressions, statements, declarations, and class members
  • Adds visitor pattern support with WalkVisitor, ConstWalkVisitor, PrintVisitor, StructuralValidator, and LintVisitor
  • Provides diagnostic system with severity levels, error collection, and filtering capabilities
  • Sets up parser state machine infrastructure and token stream handling

Reviewed Changes

Copilot reviewed 231 out of 231 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/parser/types/TypeReference.{hpp,cpp} Core type reference implementation with qualified names, type arguments, nullability, and resolution
lib/parser/types/Param.{hpp,cpp} Parameter representation with name and type
lib/parser/types/Nullable.{hpp,cpp} Nullable type wrapper
lib/parser/ast/nodes/* Complete AST node hierarchy for expressions, statements, declarations, and class members
lib/parser/ast/visitors/* Visitor pattern implementations for AST traversal and validation
lib/parser/diagnostics/* Diagnostic system with severity levels, collection, and filtering
lib/parser/states/* Parser state machine infrastructure (headers only, implementations pending)
lib/parser/pratt/* Pratt parser infrastructure for expression parsing
lib/parser/tokens/* Token stream and source tracking utilities

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +14 to +16
[[nodiscard]] std::string GetName();

[[nodiscard]] TypeReference GetType();
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GetName() and GetType() methods should return const references for consistency with the rest of the codebase. These methods copy the entire std::string and TypeReference objects on every call, which is inefficient.

Change:

[[nodiscard]] std::string GetName();
[[nodiscard]] TypeReference GetType();

To:

[[nodiscard]] const std::string& GetName() const;
[[nodiscard]] const TypeReference& GetType() const;

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@bialger bialger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the reviewed changes. In general that looks good, but there is a place for improvement

public:
virtual ~AstNode() = default;

// TODO: add positions......
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add said positions

Comment on lines +25 to +26
const TypeReference* ReturnType() const noexcept;
TypeReference* MutableReturnType() noexcept;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be much more safe to use a link here, raw pointers are undesirable in this context.

Comment on lines +18 to +19
const Block* Body() const noexcept;
Block* MutableBody() noexcept;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here and for all pointer-returning methods: use reference

Comment on lines +28 to +34
bool MethodDecl::IsStatic() const noexcept {
return is_static_;
}

void MethodDecl::SetStatic(bool is_static) noexcept {
is_static_ = is_static;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure whether we actually have static methods.

Comment on lines +54 to +58
std::string name;
std::vector<Param> params;
std::unique_ptr<TypeReference> ret_type;
std::unique_ptr<Block> body; // optional
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-public fields naming: should end with an underscore (e.g. name_)

Comment on lines +19 to +29
bool IsPublic() const noexcept;
void SetPublic(bool is_public) noexcept;

bool IsOverride() const noexcept;
void SetOverride(bool is_override) noexcept;

bool IsStatic() const noexcept;
void SetStatic(bool is_static) noexcept;

bool IsPure() const noexcept;
void SetPure(bool is_pure) noexcept;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see why there and in other classes can't be a constructor for at least non-AstNode class members?

void SetValue(bool new_value) noexcept;

private:
bool value = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yet again, style for private fields: value_

Comment on lines +12 to +13
char Value() const noexcept;
void SetValue(char new_value) noexcept;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am quite sure that in values you can do it with a constructor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement AST structure Create and push parser interfaces

3 participants